package com.example.demo.bean;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @desc: <br/>
 * @author: Jingbo Hu<br/>
 * @time：2020年08⽉16⽇<br/>
 * @version：v1.0.0<br>
 */
public class FooConsumerBootstap {

    /**
     * 使用AnnotationConfigApplicationContext可以实现基于Java的配置类加载Spring的应用上下文。避免使用application.xml进行配置。相比XML配置，更加便捷
     *
     * @param args
     */
    public static void main(String[] args) {

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(ApplicationConfig.class);
        context.refresh();

        Entitlement entitlement = (Entitlement) context.getBean("entitlement");
        String name = entitlement.getName();
        int time = entitlement.getTime();
        System.out.println("name = " + name);
        System.out.println("time = " + time);
    }
}
